package com.wf.classRoomTest.Pro;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author mpk
 * @since 2024/6/18 10:10:03
 */

public class ThreadP {

    private static ExecutorService pool;

    static {

        pool = new ThreadPoolExecutor(
                ThreadConfig.CORE_POOL_SIZE,
                ThreadConfig.MAX_POOL_SIZE,
                60L,
                TimeUnit.SECONDS,
                new LinkedBlockingDeque<>(ThreadConfig.QUEUE_SIZE),
                new ThreadPoolExecutor.AbortPolicy());
    }

    //线程池中的线程 执行任务
    public static void execute(Runnable task) {
        pool.submit(task);
    }

    public static void shutDown() {
        pool.shutdown();
    }


}
